package com.ys.servers.test.points.verticle;

import com.ys.servers.common.util.MathUtils;
import com.ys.servers.points.data.LoopTypeUnit;
import com.ys.servers.points.data.PointsLoopType;
import com.ys.servers.points.data.PointsType;

/**
 * Created by taotao on 2017/5/12.
 */
public class PointsTypeGenerator {


    public PointsType genNoLoopPointsType(String id, int maxTime, String desc, String title,
                                           String logdesc, int basicPoint, int incPointsTime, int incBaisicPoints, int order) {
        PointsType pointsType = genGeneralPointsType(id, maxTime, desc, title, logdesc, basicPoint, incPointsTime, incBaisicPoints, order);
        pointsType.setLoopType(PointsLoopType.NO_LOOP).setLoopUnit(LoopTypeUnit.NO_LOOP_UNIT);
        return pointsType;
    }


    public PointsType genTimelyLoopPointsType(String id, int maxTime, String desc, String title,
                                               String logdesc, int basicPoint, int incPointsTime, int incBaisicPoints, int order, LoopTypeUnit loopTypeUnit) {
        PointsType pointsType = genGeneralPointsType(id, maxTime, desc, title, logdesc, basicPoint, incPointsTime, incBaisicPoints, order);
        pointsType.setLoopType(PointsLoopType.TIME_LOOP).setLoopUnit(loopTypeUnit);
        return pointsType;
    }

    public PointsType genContinuousLoopPointsType(String id, int maxTime, String desc, String title,
                                                   String logdesc, int basicPoint, int incPointsTime, int incBaisicPoints, int order, LoopTypeUnit loopTypeUnit) {
        PointsType pointsType = genGeneralPointsType(id, maxTime, desc, title, logdesc, basicPoint, incPointsTime, incBaisicPoints, order);
        pointsType.setLoopType(PointsLoopType.CONTINUOUS_LOOP).setLoopUnit(loopTypeUnit);
        return pointsType;
    }

    private PointsType genGeneralPointsType(String id, int maxTime, String desc, String title,
                                            String logdesc, int basicPoints, int incPointsTime, int incBaisicPoints, int order) {
        PointsType pointsType = new PointsType().setLoopType(PointsLoopType.NO_LOOP).setLogDesc(logdesc + id).
                setMaxTime((short) 5).setDesc(desc).setTitle(title).setOrder(order).setBasicPoints(basicPoints)
                .setIncPointsTime(incPointsTime).setIncBasicPoints(incBaisicPoints).setMaxTime((short) maxTime);
        pointsType.setId(id);
        return pointsType;
    }

    public PointsType genOneUpdatePointsType(String id) {

        String desc = "desc_update" + id;
        String title = "title_update" + id;
        short type = 1;
        short loopType = 0;
        short loopUnit = 1;
        short maxTime = 5;

        PointsType pointsType = new PointsType().setLoopUnit(LoopTypeUnit.DAILY_LOOP)
                .setLoopType(PointsLoopType.CONTINUOUS_LOOP).setMaxTime(maxTime).setDesc(desc).setTitle(title).setOrder(MathUtils.getRandomInt(20));
        ;
        pointsType.setId(id);
        return pointsType;
    }
}
